//
//  UIView+ViewState.h
//  TFFoundation
//
//  Created by TFAppleWork-Summer on 2017/8/9.
//  Copyright © 2017年 TFAppleWork-Summer. All rights reserved.
//

#import <UIKit/UIKit.h>
//view
#import "TFStateView.h"

//#define kTFViewState extern const NSInteger;

typedef NSInteger kTFViewState;

///<正在加载
extern const kTFViewState kTFViewStateLoading;
///<无数据
extern const kTFViewState kTFViewStateNoData;
///<有错误
extern const kTFViewState kTFViewStateError;

/**
 StateView编辑configModel的block

 @param configModel 配置数据模型
 */
typedef void(^TFStateViewEditConfigModelBlock)(TFStateViewConfigModel * __nonnull configModel);

/**
 stateView自定义显示约束的Block

 @param stateView stateView
 */
typedef void(^TFStateViewEditConstraintsBlock)(TFStateView * __nonnull stateView);

/**
 view状态类别
 */
@interface UIView (ViewState)

/**
 当前view的状态
 */
@property (nonatomic, assign, readonly) kTFViewState tf_viewState;

/**
 状态view
 */
@property (nonatomic, weak, readonly, nullable) TFStateView *tf_stateView;

/**
 根据stateView的配置模型，显示stateView

 @param configModel 配置模型
 */
- (void)tf_showStateViewWithConfigModel:(nonnull TFStateViewConfigModel *)configModel;

/**
 根据stateView的配置模型以及自定义约束，显示stateView

 @param configModel 配置模型
 @param editConstraintsBlock 自定义显示约束的Block
 */
- (void)tf_showStateViewWithConfigModel:(nonnull TFStateViewConfigModel *)configModel editConstraintsBlock:(nullable TFStateViewEditConstraintsBlock)editConstraintsBlock;

/**
 根据view的状态显示对应的stateView

 @param viewState view的状态
 @warning 暂时只支持上面所写的几个状态，在TFStyle中都有默认的定义，如需扩展，重写定义一个常量即可.
 */
- (void)tf_showStateViewWithViewState:(kTFViewState)viewState;

/**
 根据状态获取stateView的配置模型

 @param viewState view的状态
 @return 配置模型
 */
- (nullable TFStateViewConfigModel *)tf_getStateViewConfigModelWithViewState:(kTFViewState)viewState;

/**
 移除stateView
 */
- (void)tf_removeStateView;

@end
